<?php
class ImageController extends PlatformController
{
	/**
	 * 展示相册首页
	 */
	public function indexAction()
	{
		$thumb=Factory::M('ArticleModel');
		$thumbInfo=$thumb->getThumb();
		// echo '<pre>';var_dump($thumbInfo);die();
		$this->assign('thumbInfo',$thumbInfo);
		$this->proThumb($thumbInfo);
		// $image=Factory::M('UserModel');
		// $imgInfo=$image->getImage();
		// var_dump($imgInfo);die();
		// $this->assign('$imgInfo',$imgInfo);
		$this->display('index.html');
	}
	/**
 	 * 制作缩略图
 	 */
 	public function proThumb($thumbInfo)
 	{
 	$img = imagecreatefromjpeg('./images/2.jpg');
 	$size=getimagesize('./images/2.jpg');
 	$maxw=200;
 	$maxh=150;
 	$app=$maxw/$maxh;
 	$spp=$size[0]/$size[1];
 	if($size[0]<200&&$size[1]<150)
 	{
 		$slt = imagecreate($size[0],$size[1]);
 	}
 	else
 	{
 	 	if ($spp>=$app) 
 	 	{
 	 		$width=$maxw;
 	 		$height=$maxw/$spp;
 	 	}
 	 	else
 	 	{
 	 		$height=$maxh;
 	 		$width=$maxh*$spp;
 	 	}
 	 	$slt = imagecreate($width,$height);
 	 }	
 	imagecopyresampled($slt,$img,0,0,0,0,$width,$height,$size[0],$size[1]);
 	header('content-type:image/jpeg');
 	imagejpeg($slt,'');
 	}
}